# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libassuan
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.1.1
pkgrel=2
pkgdesc="A IPC library used by some GnuPG related software (mingw-w64)"
arch=('any')
license=('GPL')
url="http://www.gnupg.org/related_software/libassuan"
depends=("${MINGW_PACKAGE_PREFIX}-libgpg-error")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=(ftp://ftp.gnupg.org/gcrypt/$_realname/$_realname-$pkgver.tar.bz2
        0001-fix-def-files.mingw.patch
        0002-enable-silent-rules.mingw.patch
        0003-remove-redef.mingw.patch
        0004-enable-gnu.mingw.patch
        0005-better-check-for-stpcpy.mingw.patch)
#install=libassuan.install
md5sums=('757243cc4a71b30ed8d8dbe784035d36'
         '1da788560d554287ef83b71d5ffb59d3'
         '714fc27f9ce94d66640ec2332defcb11'
         '4ecd01de3eafe3644c52ae12f926bc8b'
         '0cc1f06dbf9343f5ab49e8b6ce47e9fa'
         'f2a4421027182a4177f49ac2b97c8dc9')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-fix-def-files.mingw.patch
  patch -p1 -i ${srcdir}/0002-enable-silent-rules.mingw.patch
  patch -p1 -i ${srcdir}/0003-remove-redef.mingw.patch
  patch -p1 -i ${srcdir}/0004-enable-gnu.mingw.patch
  patch -p1 -i ${srcdir}/0005-better-check-for-stpcpy.mingw.patch
  
  autoreconf -fi
}

build() {
  if [ $MINGW_CHOST = "x86_64-w64-mingw32" ]; then
    CFLAGS+="-DHAVE_DOSISH_SYSTEM=1"
  fi
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
  make
}

check() {
  cd ${srcdir}/build-${CARCH}
  make check
}

package() {
  cd ${srcdir}/build-${CARCH}
  make DESTDIR=${pkgdir} install
}
